package com.lzz.bottomencapsulation.utils;

import android.content.Context;
import android.widget.Toast;

/**
 * Toast工具类
 */
public class TUtils {
    public static final boolean isTost = true;

    public static void showShort(Context context, Object content) {
        show(context, content, Toast.LENGTH_SHORT);
    }

    public static void showLong(Context context, Object content) {
        show(context, content, Toast.LENGTH_LONG);
    }

    public static void show(Context context, Object content, int time) {
        if (context == null) return;
        if (isTost) Toast.makeText(context, content + "", time).show();
    }

    private static Toast mToast;

    /**
     * 显示对话框
     *
     * @param content 要显示的内容
     */
    public static void showToast(Context context, String content) {
        if (!isTost) {
            return;
        }
        if (mToast == null) {
            mToast = Toast.makeText(context, content + "", Toast.LENGTH_SHORT);
        } else {
            mToast.setText(content + "");
        }
        mToast.show();
    }
}
